from enum import Enum, unique


# 错误码基类
# Base class for all error codes.
@unique
class ErrorCode(Enum):
    pass


# 通用错误码
# Defines common error codes that can be used across different services.
@unique
class CommonErrorCode(ErrorCode):
    # Indicates that an interface call timed out.
    TIMEOUT = 1  # 接口超时
    # Indicates that the input parameters are invalid.
    INVALID_INPUT_PARAM = 2  # 输入参数不合法
    # Indicates an internal system error.
    INTERNAL_ERROR = 3  # 系统内部错误
    # Indicates that the operation is not allowed.
    NOT_ALLOWED = 4  # 操作禁止
    # Indicates that the system is busy.
    BUSY = 5  # 系统繁忙
    # Indicates that the requested resource was not found.
    NOT_FOUND = 404  # 资源不存在



# 推理服务错误码
# Defines error codes specific to inference services.
@unique
class InferErrorCode(ErrorCode):
    # Indicates that the uploaded image is too large.
    IMG_TOO_BIG = 1000  # 上传的图片过大
    # Indicates that the requested service does not exist.
    SERVICE_NOT_EXIST = 1001  # 服务不存在
    # Indicates that the service is offline.
    SERVICE_OFFLINE = 1002  # 服务已下线
    # Indicates an internal error within the inference service.
    SERVICE_INTERNAL_EXCEPTION = 1003  # 推理服务内部错误
    # Indicates that the inference service is busy.
    SERVICE_BUSY = 1004  # 推理服务繁忙
    # Indicates that the health check for the service failed.
    DETECT_HEALTH_FAILED = 1005  # 健康检查失败


# 调用Modelarts错误码
# Defines error codes specific to calls made to ModelArts.
@unique
class ModelartsErrorCode(ErrorCode):
    # Indicates that the ModelArts interface call timed out.
    TIMEOUT = 2000  # 接口超时
    # Indicates an unknown error from ModelArts.
    UNKNOWN = 2001  # 未知错误
    # Indicates an internal error within the AI application on ModelArts; check logs.
    APP_EXCEPTION = 2002  # AI应用内部错误，请查看日志
    # Indicates a lack of resources on ModelArts.
    LACK_OF_RESOURCES = 2003  # 资源不足
    # Indicates an APIG (API Gateway) exception, typically an HTTP status code > 300.
    APIGException = 2004  # apig_exception, http code >300
    # Indicates that pulling the image from ModelArts failed.
    PULL_IMAGE_FAILED = 2005  # 镜像拉取失败
    # Indicates that the service does not exist on ModelArts.
    SERVICE_NOT_EXIST = 2006  # 服务不存在
    # Indicates that the model does not exist on ModelArts.
    MODEL_NOT_EXIST = 2007  # 模型不存在
    # Indicates that the request body sent to ModelArts was too large.
    REQUEST_ENTITY_TOO_LARGE = 2008  # 请求Body过大